package com.yiyi.credit.manage.abutment.manage.controller.dict;

import com.yiyi.credit.manage.abutment.common.bean.Response;
import com.yiyi.credit.manage.abutment.service.DictInfoService;
import com.yiyi.credit.manage.model.entity.DictInfo;
import com.yiyi.credit.manage.model.vo.DictInfoVo;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;


@RestController
@RequestMapping(value = "dict", method = RequestMethod.POST)
public class DictInfoController {

    @Autowired
    private DictInfoService dictInfoService;

    @ApiImplicitParams
            ({
                    @ApiImplicitParam(name = "code", value = "编码", required = true, dataType = "Integer", paramType = "query"),
            })
    @ApiOperation(value = "根据code查询字典信息", notes = "根据code查询字典信息")
    @RequestMapping("/queryDictInfo")
    public Response<List<DictInfo>> queryDictInfo(@RequestParam Integer code) throws Exception {

        return new Response<>(dictInfoService.queryDictInfoByCode(code));
    }

    @ApiImplicitParams
            ({
                    @ApiImplicitParam(name = "codes", value = "多个编码(英文半角逗号分割)", required = true, dataType = "Integer", paramType = "query"),
            })
    @ApiOperation(value = "根据codes查询字典信息", notes = "根据codes查询字典信息")
    @RequestMapping("/queryDictInfoByCodes")
    public Response<List<DictInfoVo>> queryDictInfoByCodes(@RequestParam String codes) throws Exception {

        return new Response<>(dictInfoService.queryDictInfoByCodes(codes));
    }

    @ApiOperation(value = "查询所有字典信息", notes = "查询所有字典信息")
    @RequestMapping("/queryAllDictInfo")
    public Response<List<DictInfo>> queryAllDictInfo() throws Exception {

        return new Response<>(dictInfoService.queryAllDictInfo());
    }

}
